/**
 * @author datutu
 */

function delconfirm(){
  if(window.confirm("请确认是否放弃？")){
   return true;
  }
  return false;
}

function editStatus(obj){
    $("#editID").val($(obj).parent().parent().find("input[title='qqid']").val());
    $("#editNick").val($(obj).parent().parent().find("td[title='nick']").text());
    $("#editQq").val($(obj).parent().parent().find("td[title='qq']").text());
    $("#editAccount").val($(obj).parent().parent().find("td[title='account']").text());
    $("#editStatus").val($(obj).parent().parent().find("input[title='status']").val());
    $.blockUI({
        message: $("#editAll"),
        css: {
            width: "410px",
            height: "365px",
            top: ($(window).height() - 365) / 2 + 'px',
            left: ($(window).width() - 410) / 2 + 'px'
        }
    });
    $('#edit_cancle').click(function(){
       $.unblockUI(); 
    });
}

function addSystemUser(obj){
    $.blockUI({
        message: $("#addAll"),
        css: {
            width: "410px",
            height: "365px",
            top: ($(window).height() - 365) / 2 + 'px',
            left: ($(window).width() - 410) / 2 + 'px'
        }
    });
    $('#add_cancle').click(function(){
       $.unblockUI(); 
    });
}

function postUserData(){
    $.post($("#addurl").val(), {username:$("#addUsername").val(), password:$("#addPassword").val(),password1:$("#verifyPassword").val(), type:$("#addType").val()}, function(resp){
       if(resp.status == 200){
           $.growlUI('提示', '添加成功!');
           window.setTimeout(reload, 1000);
       }else{
           $.growlUI('提示', '添加失败!');
       }
    }, "json")
}

function postQqData(){
	if($("#editStatus").val() == ""){
		$.growlUI('提示', '请选择正确的状态!');
		return false;
	}
    $.post($("#editurl").val(), {id:$("#editID").val(), nick:$("#editNick").val(), account:$("#editAccount").val(), qq:$("#editQq").val(), status:$("#editStatus").val(), oldStatus: $("#oldStatus-"+$("#editID").val()).val()}, function(resp){
       if(resp.status == 200){
           $.growlUI('提示', '修改成功!');
           window.setTimeout(reload, 1000);
       }else{
           $.growlUI('提示', '修改失败!');
       }
    }, "json")
}


function reload(){
    window.location.reload()
}
